#!/usr/bin/env python3.10.6
# -*- coding: utf-8 -*-
# Author: Bobby Sheng <Bobby@sky-cloud.net>
from jira import JIRA
from units.get_config_data import get_config_yaml_data
import jsonpath


def get_jira_client():
    json_data = get_config_yaml_data()
    server = jsonpath.jsonpath(json_data, "$.jira.url")[0]
    username = jsonpath.jsonpath(json_data, "$.jira.username")[0]
    password = jsonpath.jsonpath(json_data, "$.jira.password")[0]

    jira_cline = JIRA(server=server, basic_auth=(username, password))
    return jira_cline


if __name__ == '__main__':
    print(get_jira_client().search_issues(
        'project = INET AND issuetype = 故障 AND status in ("To Do", 开发中) AND assignee in (awen.cheng)',
        maxResults=-1))
